<template>
    <div><h1>学生管理</h1>
    <ADDStudent :currentCutObj="currentCutObj" @addStu="addStu"></ADDStudent>
    <ListStudent :cutBean="currentCutObj" :stuObj="stuObj" @showStudent="showStudent" @find="find"></ListStudent>
    <UpdateStudent :stuObj="stuObj"  @showStudent="showStudent"></UpdateStudent>
    </div>
</template>

<script>

import ADDStudent from './StudentManager/ADDStudent.vue'
import ListStudent from "./StudentManager/ListStudent.vue"
import UpdateStudent from "./StudentManager/UpdateStudent.vue"
export default {
    components:{ADDStudent,ListStudent,UpdateStudent},
    data(){
        return {
             stuObj:{},
            currentCutObj:{},
            cutObj1:{total:10,
                    pages:2,
            list:[{id:1,name:"张三",sex:"男",grade:80},
        {id:2,name:"请问",sex:"男",grade:70},
        {id:3,name:"阿萨",sex:"女",grade:85},
        {id:4,name:"咯是",sex:"男",grade:90},
        {id:5,name:"拍咯",sex:"男",grade:75}]},
        cutObj2:{total:10,
                    pages:2,
            list:[{id:11,name:"张1三",sex:"男",grade:80},
        {id:12,name:"请1问",sex:"男",grade:70},
        {id:13,name:"阿2萨",sex:"女",grade:85},
        {id:14,name:"咯3是",sex:"男",grade:90},
        {id:15,name:"拍1咯",sex:"男",grade:75}]}
        }
    },
    methods:{
        speak(n){
            alert("页码"+"  "+n)
        },
           showStudent(n){
               if(n==1){
                   this.currentCutObj = this.cutObj1 
               }else{
                   this.currentCutObj = this.cutObj2
               }
           },
           addStu(stuObj){
                this.cutObj2.list.push(stuObj);
           } ,
           find(stu){
               this.stuObj = stu;
               alert(this.stuObj.id);
           },

    },
    created(){
        this.showStudent(1)
    }
}
</script>

<style>

</style>